package com.demo.security.package1;

import lombok.extern.slf4j.Slf4j;

/**
 * @author LiYuhang
 * @version 0.1
 * @application  运行结果错误
 * @Date 2020/12/16 16:36
 */
@Slf4j
public class Demo1 {
    volatile static int i;
    public static void main(String[] args) throws InterruptedException {
        Runnable r = new Runnable() {
            @Override
            public void run() {
                for (int j = 0; j < 1000; j++) {
                    i++;
                }
            }
        };
        Thread thread1 = new Thread(r);
        thread1.start();
        Thread thread2 = new Thread(r);
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println(i);
    }
}
